package models

import (
	"github.com/go-playground/validator/v10"
	"gorm.io/gorm"
)

func (Package) TableName() string {
	return "erp_package"
}

// User 用户模型
type Package struct {
	gorm.Model
	MerchantId int    `gorm:"type:int;column:merchant_id;default:0;comment:'商户id'"`
	PackageNo  string `gorm:"type:varchar(64);column:package_no;default:'';comment:'包裹号'"`
	StorageId  int    `gorm:"type:int;column:storage_id;default:0;comment:'仓库id'"`
	//CreatedAt time.Time  `gorm:"column:created_at;autoCreateTime;comment:'创建时间'"`
	//UpdatedAt time.Time  `gorm:"column:updated_at;autoUpdateTime;comment:'修改时间'"`
	//DeletedAt *time.Time `gorm:"column:deleted_at;index;comment:'删除时间'"`
	Status  int `gorm:"column:status;comment:'状态'"` // 假设状态只有0,1,2,3四种值
	Storage Storage
}

type UpdatePackageDTO struct {
	MerchantId int    `json:"merchant_id"`
	StorageId  int    `json:"storage_id"`
	PackageNo  string `json:"package_no" validate:"required,max=64"`
	Status     int    `json:"status" validate:"oneof=1 2"`
}

func (dto *UpdatePackageDTO) Validate() error {
	validate := validator.New()
	return validate.Struct(dto)
}
